<?php
include 'util.php';

$playerID = $_POST['playerID'];
$i = $_POST['i'];

$statusFile = file_get_contents('src\json\gameStatus.json');
$newPokerFile = file_get_contents('src\temp\new_poker.json');

$gameStatusArray = json_decode(prepareJSON($statusFile), true);
$newPokerArray = json_decode(prepareJSON($newPokerFile), true);

$cardIndex = $gameStatusArray['cardIndex'];
// to-do 防止越界
$cards = array($newPokerArray[$cardIndex],$newPokerArray[$cardIndex+1]);

// 增加对应选手牌
$gameStatusArray['playerInfo'][$playerID-1]['cards'] = array_merge($gameStatusArray['playerInfo'][$playerID-1]['cards'],$cards);
// 修改状态
$gameStatusArray['cardIndex'] = $gameStatusArray['cardIndex']+2;


file_put_contents('src\json\gameStatus.json',json_encode($gameStatusArray));

?>